package com.uphone.kingmall.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.china.zhuoyue.R;
import com.uphone.kingmall.bean.UserShopCollectBean;
import com.uphone.kingmall.utils.CommonUtil;
import com.uphone.kingmall.utils.GlideUtils;
import com.uphone.kingmall.view.dialog.RadishDialog;

/**
 * <pre>
 *     author : 王雨
 *     e-mail :
 *     time   : 2018/07/31
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class AttentionStoreAdapter extends BaseQuickAdapter<UserShopCollectBean.DataBean, BaseViewHolder> {
    private OnFollowItemClickListener listener;

    public AttentionStoreAdapter() {
        super(R.layout.kingmall_item_attent_store);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final UserShopCollectBean.DataBean item) {
        ImageView iv = helper.getView(R.id.iv_shop_icon);
        GlideUtils.getInstance().loadCircleImage(mContext, item.getShopImg(), iv);
        helper.setText(R.id.tv_shop_name, item.getShopName() + "");

        helper.getView(R.id.tv_attent).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                CommonUtil.showAlterDialog(mContext, "取消关注？", new CommonUtil.OnAlterDialogCallBack() {
                    @Override
                    public void callBack(RadishDialog dialog, View view) {
                        if (listener != null) {
                            listener.followClick(v, helper.getLayoutPosition(), item);
                        }
                    }
                });
            }
        });
    }

    public void setOnFollowItemClickListener(OnFollowItemClickListener listener) {
        this.listener = listener;
    }

    public interface OnFollowItemClickListener {
        void followClick(View view, int position, UserShopCollectBean.DataBean item);
    }
}
